#import <UIKit/UIKit.h>
#import "MRLabel.h"

typedef NS_OPTIONS(NSUInteger, UIButtonEvents)
{
	UIControlEventTouchClick			= 1 << 9,
	UIControlEventTouchLongPress		= 1 << 10,
	UIControlEventTouchForce			= 1 << 11,
};

@interface UIButton (Extension)

@end

//
@class MRButton;

typedef void(^MRButtonEvent) (MRButton *button, UIButtonEvents event);

@protocol MRButtonDelegate <NSObject>

@optional
- (void)button:(MRButton *)button willAnimation:(CAKeyframeAnimation *)animation;
- (void)buttonDidStopAnimation:(MRButton *)button;

@end

/*===================================================================
 说明：
    自定义按钮
 ==================================================================*/
@interface MRButton : UIButton<UIApplicationDelegate>
{
	MRButtonEvent	_handler;
	BOOL			_willForce, _willPress;
	
	CGPoint			_startPoint;
	
	CGFloat			_tmrValue;
    NSTimer			*_tmrPress;
	
	UIFont			*_fontNormal, *_fontHighlighted, *_fontSelected, *_fontDisabled;
}

@property (nonatomic) id <MRButtonDelegate>	delegate;

@property (nonatomic) CGFloat		longPress;			//长按有效时长

@property (nonatomic) BOOL			allowForce;
@property (nonatomic) BOOL			allowLongPress;
@property (nonatomic) BOOL			allowAnimation;

@property (nonatomic, retain) UIImage		*image;
@property (nonatomic, retain) UIFont		*font;

@property (nonatomic, copy)	NSString		*title;

- (void)addTarget:(id)target action:(SEL)action forControlEvents:(NSUInteger)controlEvents;
- (void)removeTarget:(id)target action:(SEL)action forControlEvents:(NSUInteger)controlEvents;

- (void)setTitleFont:(UIFont *)font forState:(UIControlState)state;
- (UIFont *)titleFontForState:(UIControlState)state;

- (void)startAnimation;
- (void)stopAnimation;

- (void)didFinishOperated;	//长按或重按生效执行，子类覆盖

- (void)setHandler:(MRButtonEvent)handler;

@end
